package com.sskj.b70.v.activity;

import android.content.Context;
import android.content.Intent;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.sskj.b70.R;
import com.sskj.b70.common.App;
import com.sskj.b70.m.bean.bean.FbShop;
import com.sskj.b70.p.activity.SellerApplyPresenter;
import com.sskj.b70.utils.ClickUtil;
import com.sskj.b70.utils.ToastUtil;
import com.sskj.b70.v.base.BaseActivity;

import butterknife.BindView;

/**
 * 申请商家
 */
public class SellerApplyActivity extends BaseActivity<SellerApplyPresenter> {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.bt_apply_seller)
    Button btApplySeller;
    @BindView(R.id.apply_checkbox)
    CheckBox mApplyCheckbox;
    @BindView(R.id.tv_freeze)
    TextView tvFreeze;
    @BindView(R.id.tv_content)
    TextView tvContent;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_seller_apply;
    }

    @Override
    public SellerApplyPresenter getPresenter() {
        return new SellerApplyPresenter();
    }

    public static void start(Context context) {
        Intent starter = new Intent(context, SellerApplyActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void initView() {
        mPresenter.requestUserInfo();
        mPresenter.fbShopNumber();
        ClickUtil.click(ivBack, this::finish);
        ClickUtil.click(btApplySeller, () -> {
            if (mApplyCheckbox.isChecked()) {
                mPresenter.apply();
            } else {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.strSellerApplyActivity0));
            }
        });
    }


    public void startFabiPublish() {
        finish();
        FabiPublishActivity.start(this);
    }

    public void updateUser(FbShop data) {
        tvContent.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity1) + data.getValue() + App.INSTANCE.getString(R.string.strSellerApplyActivity2));
        tvFreeze.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity3) + data.getValue() + App.INSTANCE.getString(R.string.strSellerApplyActivity4));     // 单选框 文本
    }
}
